<template>
  <div>
    <el-alert
      title="提示" :closable="false"
      type="info"
      description="修改完重新登录有效"
      show-icon>
    </el-alert>
    <el-form ref="form" :model="passwordModel" :rules="rules">
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model.trim="passwordModel.password" />
      </el-form-item>
      <el-form-item label="再次输入" prop="email">
        <el-input type="password" v-model.trim="passwordModel.rePassword" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit('form')">修改</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<script>
import {resetPassword} from '@/api/system/tUser'

export default {

  data(){
    return{
      passwordModel:{
        password:'',
        rePassword:'',
      },
      rules:{
        password:[{required:true}],
        rePassword:[{required:true}],
      }
    }
  },
  methods: {
    submit(ref) {
      this.$refs[ref].validate(valid =>{
        if(valid){
          resetPassword(this.passwordModel).then(res =>{
            this.$message({
              type:'success',
              message:'修改成功'
            })
            this.resetForm(ref)
          })
        }
      })
    }

  }
}
</script>
